﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using PlayingCardLib;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace ReadCards
{
    class Program
    {
        
        static void Main(string[] args)
        {
            PlayingCard card;
            IFormatter bfmt = new BinaryFormatter();


            using(Stream stream = File.OpenRead(@"C:\Projects\cards"))
            {
                while(stream.Length != stream.Position)
                {
                    card = bfmt.Deserialize(stream) as PlayingCard;
                    Console.WriteLine(card.ToString());
                }
                /*
                for(int i = 0; i < 10; i++)
                {
                    // card = (PlayingCard)bfmt.Deserialize(stream);
                    card = bfmt.Deserialize(stream) as PlayingCard;
                    Console.WriteLine(card.ToString());
                }
                */
                stream.Close();
                
            }

            Console.WriteLine("Done");
            Console.ReadLine();
        }
    }
}
